module seg_mux (
    output reg[3:0] hex7,hex6,hex5,hex4,hex3,hex2,hex1,hex0,
    input [4:1] key,
    input [4:1] sw,
    input [15:0] AX_data,
    input [15:0] BX_data,
    input [15:0] CX_data,
    input [15:0] DX_data,
    input [15:0] ACC_data,
    input [15:0] MBR_data,
    input [15:0] MR_data,
    input [7:0] SP_data,
    input [7:0] MAR_data,
    input [7:0] PC_data,
    input [15:0] IR_data
);
    always @(*) begin
        if (sw[1] == 1) begin
            case (key)
            4'b1110: begin
                {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, 4'b0000, 4'b0000, MAR_data[7:4], MAR_data[3:0]};
            end
            4'b1101: begin
                {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, MBR_data[15:12], MBR_data[11:8], MBR_data[7:4], MBR_data[3:0]};
            end
            4'b1011: begin
                {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = { 4'b0000, 4'b0000, 4'b0000, 4'b0000,IR_data[15:12], IR_data[11:8], IR_data[7:4], IR_data[3:0]};
            end
            4'b0111: begin
                {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, 4'b0000, 4'b0000, SP_data[7:4], SP_data[3:0]};
            end
            default: begin
                {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, 4'b0000, 4'b0000, PC_data[7:4], PC_data[3:0]};
            end
            endcase
        end else begin
            case (key)
                4'b1110: begin
                    {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, AX_data[15:12], AX_data[11:8], AX_data[7:4], AX_data[3:0]};
                end
                4'b1101: begin
                    {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, BX_data[15:12], BX_data[11:8], BX_data[7:4], BX_data[3:0]};
                end
                4'b1011: begin
                    {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, CX_data[15:12], CX_data[11:8], CX_data[7:4], CX_data[3:0]};
                end
                4'b0111: begin
                    {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {4'b0000, 4'b0000, 4'b0000, 4'b0000, DX_data[15:12], DX_data[11:8], DX_data[7:4], DX_data[3:0]};
                end
                default: begin
                    {hex7, hex6, hex5, hex4, hex3, hex2, hex1, hex0} = {MR_data[15:12], MR_data[11:8], MR_data[7:4], MR_data[3:0], ACC_data[15:12], ACC_data[11:8], ACC_data[7:4], ACC_data[3:0]};
                end
            endcase
        end

    end

endmodule